var age_ARR1 = age_ARR,
age_ARR2 = age_ARR,
heigh_ARR1 = heigh_ARR,
heigh_ARR2 = heigh_ARR,
weigh_ARR1 = weigh_ARR,
weigh_ARR2 = weigh_ARR;
window.onload=function(){
	zeai.listEach(zeai.tag(sotab,'li'),function(obj,k){
		if(k==0 || k==3){
			obj.onclick=function(){
				if(!obj.hasClass('ed')){
					resetsotab();obj.class('ed');zeai.mask({son:o('sotab'+(k+1)),close:function(){obj.removeClass('ed');}});
				}else{resetsotab();}
			}
		}
	});	
	o('areaidA').onclick=areaidFn
	o('area2idA').onclick=area2idFn
	o('areaid').onclick=areaidFn
	o('area2id').onclick=area2idFn
	user_search.onclick=function(){
		resetsotab();
		ZeaiM.div_left({obj:user_so,w:28});
	}
	sotab4_btn.onclick=function(){ZEAI_CN_FORM_ext.submit();}
	if(!zeai.empty(o('showtype_box'))){
		var scsA = scs.split('&'),newA=[],s;
		for(var k=0;k<scsA.length;k++) {
			s=scsA[k].split('=');
			if(!zeai.empty(s[1])){
				newA.push(s[0]+'='+s[1]);
			}
		}
		zeai.listEach(zeai.tag(o('showtype_box'),'a'),function(obj,i){obj.onclick=function(){showtypeFn(newA,i);}});
	}
	ZeaiM.divMod({kind:'range',clickobj:agebtn,obj:age,end:function(e,i){o('form_age').value=e;ZEAI_CN_FORM_ext.submit();}});
	ZeaiM.divMod({kind:'range',clickobj:heighbtn,obj:heigh,end:function(e,i){o('form_heigh').value=e;ZEAI_CN_FORM_ext.submit();}});
	ZeaiM.divMod({kind:'range',obj:age,end:function(e,i){o('form_age').value=e;}});
	ZeaiM.divMod({kind:'range',obj:heigh,end:function(e,i){o('form_heigh').value=e;}});
	ZeaiM.divMod({kind:'range',obj:weigh,end:function(e,i){o('form_weigh').value=e;}});
	processHash();
}
function showtypeFn(newA,i){
	var A=[];
	for(var k=0;k<newA.length;k++) {
		ss=newA[k].split('=');
		if(ss[0]=='showtype'){
			A.push(ss[0]+'='+(i+1));
		}else{
			A.push(newA[k]);
		}
	}
	var A=A.join("&");
	zeai.openurl('user'+zeai.ajxext+A);
}
function resetsotab(){
	zeai.listEach(zeai.tag(sotab,'li'),function(obj){if(!zeai.empty(obj)){obj.removeClass('ed');}});	
	for(var k=1;k<=4;k++) {if(k==1 || k==4){  objM=o('Msotab'+k);if(!zeai.empty(objM)){objM.click();}  }}
}
function areaidFn(){
	ZeaiM.div_up({obj:areabox,h:36});
	ZEAI_area({areaid:o('form_areaid').value,areatitle:o('form_areatitle').value,ul:areabox.children[0],bx:true,str:'job',end:function(z,e){
		o('areatitle').html(e);o('areatitle').class('ed');
		o('areatitleA').html(e);o('areatitleA').class('ed');
		o('form_areaid').value=z;
		o('form_areatitle').value=e;
	}});
}
function area2idFn(){
	ZeaiM.div_up({obj:areabox2,h:36});
	ZEAI_area({areaid:o('form_area2id').value,areatitle:o('form_area2title').value,ul:areabox2.children[0],bx:true,str:'hj',datastr:'hj',end:function(z,e){
		o('area2title').html(e);o('area2title').class('ed');
		o('area2titleA').html(e);o('area2titleA').class('ed');
		o('form_area2id').value=z;
		o('form_area2title').value=e;
	}});
}
function gpsbtnFn(cook_longitude,cook_latitude,cook_areatitle){
	var jurl=MHOST+'/user'+zeai.ajxext+'t=gps&showtype='+showtype;
	zeai.ajax({url:MHOST+'/user'+zeai.ajxext+'submitok=ajax_gps',js:1},function(e){var rs=zeai.jsoneval(e);
		if(rs.flag==1){
			zeai.openurl(jurl);
		}else{
			if(browser=='wx'){
				wx.getLocation({
					type: 'wgs84',
					success: function (res) {
						var latitude = res.latitude,longitude= res.longitude;
						zeai.ajax({url:MHOST+'/user'+zeai.extname,js:1,data:{submitok:'ajax_gps_save',latitude:latitude,longitude:longitude}},function(e){var rs=zeai.jsoneval(e);
							if(rs.flag==1){
								zeai.openurl(jurl);	
							}else{
								//zeai.alert('您已拒绝授权定位，将无法使用附近的人');
								setmap(showtype,cook_longitude,cook_latitude,cook_areatitle);
							}
						});
					},
					cancel: function (res) {zeai.alert('您已拒绝授权定位，将无法使用附近的人');},
					fail: function (res) {
						//zeai.msg('请开启手机本身的GPS定位后并同意授权',{time:4});
						setmap(showtype,cook_longitude,cook_latitude,cook_areatitle);
					}
				});
			}else if(browser=='app'){
				plus.geolocation.getCurrentPosition(function(p){
					zeai.ajax({url:MHOST+'/user'+zeai.extname,js:1,data:{submitok:'ajax_gps_save',latitude:p.coords.latitude,longitude:p.coords.longitude}},function(e){var rs=zeai.jsoneval(e);
						if(rs.flag==1){zeai.openurl(jurl);}else{
							//zeai.msg('定位失败:' + rs.msg,{time:4});
							setmap(showtype,cook_longitude,cook_latitude,cook_areatitle);
						}
					});	
				}, function(e){
					//zeai.msg('获取定位失败:' + e.message,{time:4});
					setmap(showtype,cook_longitude,cook_latitude,cook_areatitle);
				});
			}else{
				//zeai.msg('请使用微信打开并同意获取自己的定位',{time:4});
				setmap(showtype,cook_longitude,cook_latitude,cook_areatitle);
			}
		}
	});
	function setmap(showtype,cook_longitude,cook_latitude,cook_areatitle){zeai.openurl(MHOST+'/map_set.php?kind=u&showtype='+showtype+'&longitude='+cook_longitude+'&latitude='+cook_latitude+'&areatitle='+cook_areatitle);}
}
